<template>
	<view class="movie-container">
		<view class="panel">
			<view>电影名称: {{this.mov_title}}</view>
			<view>类型: {{this.mov_type}}</view>
			<view>制片国家: {{this.mov_area}}</view>
			<view>导演: {{this.mov_director}}</view>
			<view>上映日期: {{this.mov_year}}</view>
			<view>豆瓣评分: {{this.mov_rating}}</view>
			<view>名言: {{this.mov_text}}</view>
			<view>{{this.mov_title}}的剧情简介 · · · · · ·</view>
			<view>{{this.mov_intro}}</view>
			<view>
				<uni-link :href="this.mov_link">电影链接</uni-link>
			</view>
			<view>
				<image :src="this.mov_pic"></image>
			</view>
			<view>海报地址:
			</view>
			<view>
				<image :src="this.poster_url"></image>
			</view>
			<view>时间: {{this.date}}</view>
		</view>
	</view>
</template>

<script>
	import sqlite from '../../utils/sqlite.js'
	import service from '../../utils/http.js'
	export default {
		data() {
			return {
				date: '', //时间
				mov_area: '', //发布地区
				mov_director: '', //导演
				mov_intro: '', //介绍
				mov_link: '', //链接
				mov_pic: '', //图片
				poster_url: '', //url
				mov_rating: '', //推荐指数
				mov_text: '', //
				mov_title: '', //电影名称
				mov_type: '', //电影类型
				mov_year: '', //上映时间
			};
		},
		onLoad() {
			this.getMovieList()
		},
		methods: {
			getMovieList() {
				service.get('/api/common/OneFilm')
					.then(response => {
						const info = response.result
						this.date = info.date
						this.mov_area = info.mov_area
						this.mov_director = info.mov_director
						this.mov_intro = info.mov_intro
						this.mov_link = info.mov_link
						this.mov_pic = info.mov_pic
						this.poster_url = info.poster_url
						this.mov_rating = info.mov_rating
						this.mov_text = info.mov_text
						this.mov_title = info.mov_title
						this.mov_type = info.mov_type.join(',')
						this.mov_year = info.mov_year
						this.createMovie()
					})
					.catch(error => {
						console.error(error);
					});
			},
			async createMovie() {
				let sqltxt = [
					'CREATE TABLE IF	NOT EXISTS dayMovie(id INTEGER PRIMARY KEY,mov_title varchar(20),mov_type varchar(200),mov_area varchar(20),mov_director varchar(20),mov_year varchar(20),mov_rating varchar(4),mov_text varchar(500),mov_intro varchar(8000),mov_link varchar(100),mov_pic varchar(100),poster_url varchar(100 ),date varchar(100))',
					"insert into payList(mov_title,mov_type,mov_area,mov_director,mov_year,mov_rating,mov_text,mov_intro,mov_link,mov_pic,poster_url,date) values('" +
					mov_title + "','" + mov_type + "','" + mov_area +
					"','" + mov_director +
					"','" + mov_year + "','" + mov_rating +
					"','" + mov_text + "','" + mov_intro + "','" + mov_link +
					"','" + mov_pic + "','" + poster_url + "','" + date + "')"
				];
				console.log(sqltxt)
				let res = await sqlite.executeSQL(sqltxt);
				if (res.code === 1) {
					uni.showToast({
						title: '成功',
						duration: 1500,
						icon: 'none'
					})
				} else {
					uni.$showMsg(res.msg)
				}
			}
		}
	}
</script>

<style lang="scss">
.movie-container{
	margin-left: 20px;
	margin-right: 20px;
	line-height: 30px;
}
</style>